﻿#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

class Solution {
public:
	vector<vector<string>> ans;
	void search(vector<int>& C, int cur, int n) {
		if (cur == n)
			addsol(C);
		else {
			for (int i = 0; i < n; i++) {
				C[cur] = i;
				bool flag = true;
				for (int j = 0; j < cur; j++) {
					if (C[cur] == C[j] || cur - C[cur] == j - C[j] || cur + C[cur] == j + C[j]) {
						flag = false;
						break;
					}
				}
				if (flag)
					search(C, cur + 1, n);
			}
		}
	}
	void addsol(vector<int>& C) {
		int n = C.size();
		vector<string> oneans;
		for (int i = 0; i < n; i++) {
			string tmp(n, '.');
			tmp[C[i]] = 'Q'; 
			oneans.push_back(tmp);
		}
		ans.push_back(oneans);
	}
	vector<vector<string>> solveNQueens(int n) {
		vector<int> C(n);
		search(C, 0, n);
		return ans;
	}
};

int main()
{
	Solution sol;
	//vector<vector<int>> test = { {1},{2},{3},{} };
	string test(40000,'a');
	shared_ptr<int> p = make_shared<int>(42);
	{
		shared_ptr<int> q(p);
	}
	cout << *p << endl;
	cout << endl;
}
